package top.amot.forceview.theme

import android.content.Context
import android.graphics.Color
import android.graphics.Paint
import top.amot.forceview.theme.I_LinkStyle
import android.text.TextPaint
import top.amot.forceview.util.UiUtil
import top.amot.forceview.ForceDrawer
import top.amot.forceview.theme.I_NodeStyle
import android.util.SparseIntArray
import top.amot.forceview.theme.DefaultLinkStyle
import top.amot.forceview.theme.DefaultNodeStyle
import top.amot.forceview.theme.I_Theme

class DefaultNodeStyle(context: Context) : I_NodeStyle {
    override val paint: Paint = Paint(Paint.ANTI_ALIAS_FLAG)
    override val textPaint: TextPaint
    override val colorArray: SparseIntArray

    init {
        paint.color = Color.LTGRAY
        paint.style = Paint.Style.FILL_AND_STROKE
        textPaint = TextPaint(Paint.ANTI_ALIAS_FLAG)
        textPaint.textAlign = Paint.Align.CENTER
        textPaint.textSize = UiUtil.sp2px(context, ForceDrawer.DEFAULT_TEXT_SIZE_SP.toDouble()).toFloat()
        textPaint.color = Color.WHITE
        colorArray = SparseIntArray()
        colorArray.put(0, -0x292a7)
        colorArray.put(1, -0x24bf6)
        colorArray.put(2, -0x933cac)
        colorArray.put(3, -0xaf7328)
        colorArray.put(4, -0xbbcd6c)
        colorArray.put(ForceDrawer.LOW, -0x67bc79)
    }

    override val nodeColor: Int
        get() = Color.GRAY

    override fun getColor(level: Int): Int {
        var level = level
        if (level >= colorArray.size() - 1 || level < 0) {
            level = ForceDrawer.LOW
        }
        return colorArray[level]
    }

    override val selectNodeColor: Int
        get() = Color.GRAY
}